<template>
  <transition name="fade"
              @after-leave="handleAfterLeave">
    <div class="confirm-container"
         v-show="visible">
      <div class="confirm-wrapper">
        <p class="title">
          <span>{{ title }}</span>
        </p>
        <p class="desc">{{ desc }}</p>
        <div class="footer">
          <span class="cancel"
                @click="close">再看看</span>
          <span class="confirm"
                @click="confirm">确定</span>

        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Confirm',
  data () {
    return {
      visible: false,
      successCb: undefined,
      title: '',
      desc: '',
      loading: false,
    }
  },
  methods: {
    handleAfterLeave () {
      this.$destroy(true);
      this.$el.parentNode.removeChild(this.$el);
    },
    close () {
      this.visible = false;
      if (typeof this.cancelCb === 'function') {
        this.cancelCb();
      }
    },
    confirm () {
      this.visible = false;
      if (typeof this.confirmCb === 'function') {
        this.confirmCb(this);
      }
    },
    login () {
    }
  },
  mounted () {
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.confirm-container {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 100vw;
  background: rgba(0, 0, 0, 0.6);
  z-index: $maxIndex;
  .confirm-wrapper {
    position: relative;
    margin: 3rem auto 0;
    width: 5.6rem;
    height: 3.2rem;
    background-color: #fff;
    border-radius: 0.16rem;
    font-size: 0.24rem;
    overflow: hidden;
    .title {
      margin-top: 0.7rem;
      text-align: center;
      width: 100%;
      color: #000000;
      line-height: 1;
      font-family: PingFang-SC-Medium;
      font-weight: bold;
      font-size: 0.32rem;
      text-align: center;
    }
    .desc {
      margin-top: 0.3rem;
      font-size: 0.24rem;
      color: #999999;
      text-align: center;
    }
    .footer {
      margin-top: 0.6rem;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 0.8rem;
      line-height: 0.8rem;
      span {
        text-align: center;
        width: 2.2rem;
        height: 0.64rem;
        line-height: 0.64rem;
        border-radius: 0.32rem;
      }
      .confirm {
        margin-left: 0.23rem;
        background-color: $them;
        color: #fff;
      }
      .cancel {
        color: #999999;
        background-color: #ebebeb;
      }
    }
  }
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>
